<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      label-width="300"
    >
      <el-form-item label="监控内容类型" prop="ipaddr">
        <el-select v-model="queryParams.ipaddr" placeholder="全部项目">
          <el-option
            v-for="item in projectOptions"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="监控类型" prop="userName">
        <el-select v-model="queryParams.userName" placeholder="全部类型">
          <el-option
            v-for="item in monitoringType"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="违规等级" prop="userName">
        <el-select v-model="queryParams.userName" placeholder="全部类型">
          <el-option
            v-for="item in ViolationLevel"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="纳入监控时间" prop="userName">
        <el-date-picker
          v-model="value1"
          type="daterange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
        >
          搜索
        </el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">
          重置
        </el-button>
      </el-form-item>
    </el-form>
    <el-table
      v-loading="loading"
      :data="list.slice((pageNum - 1) * pageSize, pageNum * pageSize)"
      style="width: 100%"
    >
      <el-table-column label="序号" type="index" align="center">
        <template slot-scope="scope">
          <span>{{ (pageNum - 1) * pageSize + scope.$index + 1 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="内容ID" align="center" prop="" width="120" />
      <el-table-column label="内容" align="center" prop="" width="120" />
      <el-table-column label="链接" align="center" prop="" width="120" />
      <el-table-column label="发布人" align="center" prop="" width="" />
      <el-table-column label="发布IP" align="center" prop="" width="" />
      <el-table-column
        label="是否实名认证"
        align="center"
        prop=""
        width="100"
      />
      <el-table-column label="发布时间" align="center" prop="" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.loginTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="内容类型" align="center" prop="" width="" />
      <el-table-column label="监控类型" align="center" prop="" width="" />
      <el-table-column label="监控时间" align="center" prop="" width="" />
      <el-table-column label="违规等级" align="center" prop="" width="" />
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon=""
            @click="dialogShow(scope.row)"
            v-hasPermi="['monitor:online:forceLogout']"
          >
            查看详情
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="pageNum"
      :limit.sync="pageSize"
    />
  </div>
</template>

<script>
import { list } from "@/api/monitor/online";

export default {
  name: "Online",
  data() {
    return {
      projectOptions:[
         {
          value: "0",
          label: "全部项目",
        },
        {
          value: "1",
          label: "文章",
        },
        {
          value: "2",
          label: "评论",
        },
        {
          value: "3",
          label: "视频",
        },
      ],
      monitoringType:[
         {
          value: "0",
          label: "全部类型",
        },
        {
          value: "1",
          label: "涉黄",
        },
        {
          value: "2",
          label: "涉政",
        },
        {
          value: "3",
          label: "涉赌",
        },
         {
          value: "4",
          label: "涉赌",
        },
         {
          value: "5",
          label: "宗教",
        },
          {
          value: "6",
          label: "迷信",
        },
      ],
      ViolationLevel:[
        {
          value: "0",
          label: "全部类型",
        },
        {
          value: "1",
          label: "高",
        },
        {
          value: "2",
          label: "中",
        },
        {
          value: "3",
          label: "低",
        },
      ],
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 表格数据
      list: [],
      pageNum: 1,
      pageSize: 10,
      // 查询参数
      queryParams: {
        ipaddr: undefined,
        userName: undefined,
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询登录日志列表 */
    getList() {
      this.loading = true;
      list(this.queryParams).then((response) => {
        this.list = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    /** 强退按钮操作 */
    dialogShow(row) {
      this.$router.push("/publicOpinion/contenDetails");
    },
  },
};
</script>
<style lang="scss" scoped>
.dialogDom {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  text-align: left;
  > div {
    width: 30%;
    margin-right: 2%;
    margin-bottom: 2%;
  }
}
.dialogDiv {
  margin-bottom: 2%;
}
</style>
